home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 3152 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: news.iag.net!news
  2. From: jatmon@iag.net (John R Buchan)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Help!
  5. Date: 26 Jan 1996 15:42:59 GMT
  6. Organization: Internet Access Group, Orlando, Florida
  7. Message-ID: <4easq3$irl@news.iag.net>
  8. References: <4ea5p4$j0s@ratree.psu.ac.th>
  9. NNTP-Posting-Host: pm3-orl27.iag.net
  10. X-Newsreader: WinVN 0.99.7
  11.  
  12. In article <4ea5p4$j0s@ratree.psu.ac.th>, s3610165@maliwan.psu.ac.th says...
  13. >
  14. >Dear all
  15. >
  16. >        There is a file, hi.bat, in my 'h:\data' directory and I try to 
  17. >run it by C program but it fail. Please, advice to me?
  18. >
  19. >Source:
  20. >
  21. >#include<stdio.h>
  22. >#include<stdlib.h>
  23. >#include<conio.h>
  24. >#include<dir.h>
  25. >
  26. >main()
  27. >{
  28. >clrscr();
  29. >chdir("h:\data");
  30. >system("hi.bat");
  31. >getch();
  32. >}
  33.  
  34. It would help to have some idea of what happens when it fails (eg, what 
  35. error message do you get?).  However, one apparent problem in the code is
  36. the chdir statement.  Since, I am not aware of any character constant '\d',
  37. I am assuming that you are trying to include a backslash in the string.
  38. The backslash is an escape character in strings ( it is used to indicate
  39. that the next character(s) has some special meaning), you need to use a 
  40. double backslash '\\' to actually include one in a string.  Look up the
  41. character constants in your manual or help system. Try:
  42.  
  43.   chdir("h:\\data");
  44.  
  45. Another option is to use a slash instead.  Only DOS's command line requires
  46. the backslash.
  47.  
  48.   chdir("h:/data");
  49.  
  50. -- 
  51. John R Buchan           -:|:-     Looking for that elusive FAQ?  ftp to:
  52. jatmon@mail.iag.net     -:|:-     rtfm.mit.edu /pub/usenet-by-group/....
  53.  
  54.